﻿Imports DTO
Imports BUS

Public Class fmLoaiPhong

    Private Sub ButtonThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonThoat.Click
        Me.Close()
    End Sub

    Private Sub fmLoaiPhong_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As List(Of LoaiPhongDto)
        Dim bus As New LoaiPhongBus()
        ds = bus.LayDanhSach()
        dgvDanhSachLoaiPhong.Rows.Clear()
        For i As Integer = 0 To ds.Count - 1
            dgvDanhSachLoaiPhong.Rows.Add(ds(i).MaLoaiPhong, ds(i).TenLoaiPhong, ds(i).DonGia)
        Next
    End Sub


    Private Sub ButtonThem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonThem.Click
        If (txtLoaiPhong.Text = "") Then
            MessageBox.Show("Bạn chưa nhập tên hạng.", "Chú ý !")
        End If

        Dim lpDTO As New LoaiPhongDto()
        lpDTO.TenLoaiPhong = txtLoaiPhong.Text.Trim()
        lpDTO.DonGia = Double.Parse(txtDonGia.Text.Trim())
        'goi BUS
        ' Dim kq As Integer
        Dim bus As New LoaiPhongBus()
        bus.ThemLoaiPhong(lpDTO)
        fmLoaiPhong_Load(sender, e)
       
    End Sub

    Private Sub dgvDanhSachLoaiPhong_CellContentDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvDanhSachLoaiPhong.CellContentDoubleClick

    End Sub

    Private Sub dgvDanhSachLoaiPhong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgvDanhSachLoaiPhong.Click

        Dim temp As Integer
        temp = dgvDanhSachLoaiPhong.CurrentRow.Index
        txttendoi.Text = dgvDanhSachLoaiPhong.Rows.Item(temp).Cells("LoaiPhong").Value.ToString()
        txtgiadoi.Text = dgvDanhSachLoaiPhong.Rows.Item(temp).Cells("DonGia").Value.ToString()
        txtloaicapnhat.Text = dgvDanhSachLoaiPhong.Rows.Item(temp).Cells("STT").Value.ToString()

    End Sub

   
    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        If (txttendoi.Text = "") Then

            MessageBox.Show("Bạn hãy chọn Loại phòng cần cập nhật", "Chú ý !")

        End If

        Dim lpDTO As New LoaiPhongDto()
        lpDTO.TenLoaiPhong = txttendoi.Text.Trim()
        lpDTO.DonGia = Double.Parse(txtgiadoi.Text.Trim())
        lpDTO.MaLoaiPhong = Integer.Parse(txtloaicapnhat.Text.Trim())
        'goi BUS
        ' Dim kq As Integer
        Dim bus As New LoaiPhongBus()
        bus.CapNhatLoaiPhong(lpDTO)
        fmLoaiPhong_Load(sender, e)
    End Sub

   

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click

    End Sub
End Class